home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-06 | 3.5 KB | 139 lines | [TEXT/CWIE] |
- {•This sourcecode is an example for creating a FKey coderesource with•}
- {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
- {•for free use in any Shareware or Freeware product as a way to thank all•}
- {•programmers who share code snippets. You may put this sources on any•}
- {•CD ROM or any Archive Server but you may not sell it. •}
-
- {• For comments please write to <hoerster@muenster.de>•}
-
-
-
-
-
- unit EdressExtractor;
- interface
-
- uses
- Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,PascalA4,
- QuickDraw, ToolUtils, Memory, LowMem, Scrap;
-
- {$MAIN}
-
- procedure main;
-
- implementation
-
- const
- step = 1000;
- semikolon = ';';
- komma = ',';
- colon = ':';
- space = ' ';
- openbracket = '<';
- closebracket = '>';
- tab = char(ord(9));
- esc = char(ord(27));
- Enter = char(ord(3)); {the enter character}
- Return = char(ord(13)); {the return character}
-
-
- procedure Fillthearray(myclipHandle: handle;resulthdl:handle; myclipsize: longint);
- type
- chararray=packed array[1..1]of char;
- charptr=^chararray;
- charhdl=^charptr;
- var
- charcount, startposition: longint;
- count: longint;
- readbuffer: str63;
- myerr:oserr;
- done, found: boolean;
- begin
- readbuffer := 'o';
- done := false;
- startposition := 0;
- count := 0;
- repeat
- count := count+1;
- if count>myclipsize then
- done:=true
- else
- begin
- //readbuffer[1]:=charhdl(myclipHandle)^^[count];
- if (ord(char(charhdl(myclipHandle)^^[count]))<45)|
- ((ord(char(charhdl(myclipHandle)^^[count]))>57) & (ord(char(charhdl(myclipHandle)^^[count]))<64)) then
-
- startposition:=count;
- if (charhdl(myclipHandle)^^[count] = '@') then
- begin
- count:= startposition;
- found := false;
- charcount := 0;
- repeat
- charcount := charcount + 1;
- count:=count+1;
-
- {if (readbuffer[1] in [space, tab, enter, return,
- openbracket, closebracket, semikolon, komma, colon]) then}
- if (ord(char(charhdl(myclipHandle)^^[count]))<45)|
- ((ord(char(charhdl(myclipHandle)^^[count]))>57) & (ord(char(charhdl(myclipHandle)^^[count]))<64)) then
- found := true
- until found | (charcount > 50);
- if found=true then
- begin
- readbuffer[0]:=char(ord(charcount));
- blockmove( pointer(ord4(myclipHandle^)+startposition),@readbuffer[1],charcount-1);
- readbuffer[charcount] := return;
- if pos('.',readbuffer)>0 then
- myerr:=PtrAndHand(@readbuffer[1],resulthdl,charcount);
- readbuffer := 'o';
- end;
- startposition:=count;
- end;
- end;
- until (done);
- end;
-
- procedure dopaste;
- const
- pastecode=2422;
- var
- qel: EvQelPtr;
- begin
- if ppostevent(3, pastecode, qel) = noerr then
- qel^.evtqmodifiers := cmdkey;
- end;
-
-
- procedure main;
- var
- oldA4: LongInt;
- myerr:oserr;
- myclipsize,templongint: longint;
- myclipHandle: handle;
- resulthdl:handle;
- begin
- oldA4 := SetCurrentA4;
- myclipsize := GetScrap(nil, 'TEXT', templongint);
- resulthdl:=newhandlesys(0);
- mycliphandle := Tempnewhandle(myclipsize,myerr);
-
- if memerror=noerr then
- begin
- myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
- if myclipsize > 0 then
- begin
- Fillthearray(myclipHandle,resulthdl,myclipsize);
- hlock(resulthdl);
- myerr := ZeroScrap;
- myerr := putscrap(gethandlesize(resulthdl), 'TEXT', resulthdl^);
- hunlock(resulthdl);
- dopaste;
- end;
- end;
- TempDisposeHandle(myCliphandle,myerr);
- oldA4 := SetA4(oldA4);
- end;
- end.
-
-